var http = require('http');
var url = require('url');

function start(router) {

    var onRequest = function (req, res) {

        var pathName = url.parse(req.url).pathname;
        console.log('Request for' + pathName);
        router(pathName);
        res.writeHead(200,{'Content-Type':'text/plain'});
        res.write('Hello World!');
        res.end();

    };
    http.createServer(onRequest).listen(8888);
    console.log('启动服务。');
}

exports.start = start;